const axios = require('axios')
require('dotenv').config(); // 加载 .env 文件到 process.env

const {WX_APPID, WX_SECRET} = process.env

const appid = WX_APPID
const secret = WX_SECRET

class WeiXin {
    async getWxOauthToken(code) {
        const res = await axios.get('https://api.weixin.qq.com/sns/jscode2session',{
            params:{
                appid,
                secret,
                js_code: code,
                grant_type: 'authorization_code'
            }
        })
        return res
    }
}

module.exports = new WeiXin()
